package helpers;

import java.io.Serializable;

import data.DataManager.BlockType;

/**
 * Used for working with types of blocks.
 * 
 * @author tomas.zima
 *
 */
public class BlockTypeInfo implements Serializable
{
	/**
	 * Returns basic block of type. For example,
	 * if player breaks some blocks, its type will change.
	 * However, you wouldn't want to add these broken blocks
	 * into player's repositary, so this is the idea of this 
	 * method: to get basic type.
	 * 
	 * @param type
	 * @return
	 */
	public static BlockType getBasicType(BlockType type)
	{
		switch (type)
		{
			case BLOCK_BEDROCK:
				return BlockType.BLOCK_BEDROCK;
				
			case BLOCK_CACTUS:
			case BLOCK_CACTUS_BREAK:
				return BlockType.BLOCK_CACTUS;
				
			case BLOCK_CACTUS_TOP:
			case BLOCK_CACTUS_TOP_BREAK:
				return BlockType.BLOCK_CACTUS_TOP;
				
			case BLOCK_COAL:
			case BLOCK_COAL_BREAK:
				return BlockType.BLOCK_COAL;
				
			case BLOCK_DIAMOND:
			case BLOCK_DIAMOND_BREAK:
				return BlockType.BLOCK_DIAMOND;
				
			case BLOCK_DIRT:
			case BLOCK_DIRT_BREAK:
				return BlockType.BLOCK_DIRT;
				
			case BLOCK_FLOWER_RED:
				return BlockType.BLOCK_FLOWER_RED;
				
			case BLOCK_FLOWER_YELLOW:
				return BlockType.BLOCK_FLOWER_YELLOW;
				
			case BLOCK_GOLD:
			case BLOCK_GOLD_BREAK:
				return BlockType.BLOCK_GOLD;
				
			case BLOCK_GRASS:
			case BLOCK_GRASS_BREAK:
				return BlockType.BLOCK_GRASS;
				
			case BLOCK_IRON:
			case BLOCK_IRON_BREAK:
				return BlockType.BLOCK_IRON;
				
			case BLOCK_SAMPLING:
				return BlockType.BLOCK_SAMPLING;
				
			case BLOCK_SAND:
			case BLOCK_SAND_BREAK:
				return BlockType.BLOCK_SAND;
				
			case BLOCK_SHROOM_BROWN:
				return BlockType.BLOCK_SHROOM_BROWN;
				
			case BLOCK_SHROOM_RED:
				return BlockType.BLOCK_SHROOM_RED;
				
			case BLOCK_STONE:
			case BLOCK_STONE_BREAK:
				return BlockType.BLOCK_STONE;
				
			case BLOCK_TREETOP_BOTTOM_LEFT:
			case BLOCK_TREETOP_BOTTOM_MIDDLE:
			case BLOCK_TREETOP_BOTTOM_RIGHT:
			case BLOCK_TREETOP_MIDDLE_LEFT:
			case BLOCK_TREETOP_MIDDLE_MIDDLE:
			case BLOCK_TREETOP_MIDDLE_RIGHT:
			case BLOCK_TREETOP_TOP_LEFT:
			case BLOCK_TREETOP_TOP_MIDDLE:
			case BLOCK_TREETOP_TOP_RIGHT:
			case BLOCK_TREE_BOTTOM:
			case BLOCK_TREE_BOTTOM_BREAK:
			case BLOCK_TREE_LEAVES_LEFT:
			case BLOCK_TREE_LEAVES_RIGHT:
			case BLOCK_TREE_MIDDLE:
			case BLOCK_TREE_MIDDLE_BREAK:
			case BLOCK_TREE_MIDDLE_LEFT:
			case BLOCK_TREE_MIDDLE_LEFT_BREAK:
			case BLOCK_TREE_MIDDLE_RIGHT:
			case BLOCK_TREE_MIDDLE_RIGHT_BREAK:
				return BlockType.BLOCK_TREE_MIDDLE;
				
			default:
				return BlockType.BLOCK_NONE;
		}
	}
	
	public static BlockType getBrokenBlockType(BlockType blockType)
	{
		switch (blockType)
		{
		case BLOCK_CACTUS:
			return BlockType.BLOCK_CACTUS_BREAK;
			
		case BLOCK_CACTUS_TOP:
			return BlockType.BLOCK_CACTUS_TOP_BREAK;
			
		case BLOCK_COAL:
			return BlockType.BLOCK_COAL_BREAK;
			
		case BLOCK_DIAMOND:
			return BlockType.BLOCK_DIAMOND_BREAK;
			
		case BLOCK_DIRT:
			return BlockType.BLOCK_DIRT_BREAK;
			
		case BLOCK_GOLD:
			return BlockType.BLOCK_GOLD_BREAK;
			
		case BLOCK_GRASS:
			return BlockType.BLOCK_GRASS_BREAK;
			
		case BLOCK_IRON:
			return BlockType.BLOCK_IRON_BREAK;
			
		case BLOCK_SAND:
			return BlockType.BLOCK_SAND_BREAK;
			
		case BLOCK_STONE:
			return BlockType.BLOCK_STONE_BREAK;
			
		case BLOCK_TREE_BOTTOM:
			return BlockType.BLOCK_TREE_BOTTOM_BREAK;
			
		case BLOCK_TREE_MIDDLE:
			return BlockType.BLOCK_TREE_MIDDLE_BREAK;
			
		case BLOCK_TREE_MIDDLE_LEFT:
			return BlockType.BLOCK_TREE_MIDDLE_LEFT_BREAK;
			
		case BLOCK_TREE_MIDDLE_RIGHT:
			return BlockType.BLOCK_TREE_MIDDLE_RIGHT_BREAK;
			
		default:
			return BlockType.BLOCK_NONE;
		}
	}
}
